<?php
/***************************************
*  Class Name: BM_PHPForm 1.0          *
*  Author: Peyman Hooshmandi Raad      *
*  Email: phooshmand@gmail.com         *
*  Date: 20 Jan, 2007                  *
***************************************/

class BM_PHPForm
	{
	var $strClassName = "BM_PHPForm";
	var $strVersion   = "1.0";
	var $strAuthor    = "Peyman Hooshmandi Raad";
	var $strEmail     = "phooshmand@gmail.com";
	var $strUrl       = "http://www.velenjak.com/downloads/BM_PHPForm-1.0.zip";
	var $strDate      = "20 Jan, 2007";

	var $strFileName = "";
	var $strIndent   = "";
	var $arrErrMsgs  = array();
	var $arrInfMsgs  = array();
	var $arrPostData = array();
	var $blnLocator  = false;
		
	function BM_PHPForm()
		{
		preg_match("/[^\/]*$/", $_SERVER['PHP_SELF'], $arrSub);
		$this->strFileName = $arrSub[0];
		if ($this->IsPost())
			{
			while(list($strKey, $strVal) = each($_POST))
				{
					if (is_array($strVal)){
						$this->arrPostData[$strKey] = $strVal;
					}else{
						$strVal = trim($strVal);
						$strVal = $this->StripSlashes($strVal);
						$this->arrPostData[$strKey] = $strVal;
					}
				}
			}
		}
	
	function Open($strId, $strCaption, $arrOtherAttributes = array(), $strEnctype = "multipart", $strAction = "", $strMethod = "post")
		{
		$strId = (($strId == "") ? "" : " id=\"".$strId."\"" );
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strAction = (($strAction == "") ? $this->strFileName : $strAction );
		switch ($strMethod)
			{
			case "get":
				$strMethod = "get";
				break;
			case "post":
				$strMethod = "post";
				break;
			default:
				$strMethod = "post";
				break;
			}

		switch ($strEnctype)
			{
			case "text":
				$strEnctype = "text/plain";
				break;
			case "multipart":
				$strEnctype = "multipart/form-data";
				break;
			case "urlencoded":
				$strEnctype = "application/x-www-form-urlencoded";
				break;
			default:
				$strEnctype = "application/x-www-form-urlencoded";
				break;
			}
		return $this->strIndent."<form".$strId." action=\"".$strAction."\" method=\"".$strMethod."\"".$strOtherAttributes." enctype=\"".$strEnctype."\">\r\n".$this->strIndent."  <fieldset>\r\n".$this->strIndent."    <legend>".$strCaption."</legend>\r\n".$this->strIndent."    <div id=\"form-items\">\r\n";
		}
	
	function Close()
		{
		return $this->strIndent."    </div>\r\n".$this->strIndent."  </fieldset>".$this->strIndent."\r\n".$this->strIndent."</form>\r\n";
		}	
	
	function TextBox($strId, $strLabel, $strValue, $arrOtherAttributes = array(), $strType = "text", $intMaxLength = 0, $intTabIndex = NULL)
		{
			return BM_PHPForm::TextBox2($strId, $strLabel, $strValue, $arrOtherAttributes, $strType, $intMaxLength, $intTabIndex,1);
		}
	
	function TextBox2($strId, $strLabel, $strValue, $arrOtherAttributes = array(), $strType = "text", $intMaxLength = 0, $intTabIndex = NULL,$position = 2){
		switch ($strType)
			{
			case "text":
				$strType = "text";
				break;
			case "password":
				$strType = "password";
				break;
			default:
				$strType = "text";
				break;
			}
		$strMaxLength = (($intMaxLength > 0) ? " maxlength=\"".$intMaxLength."\"" : "" );
		$strTabIndex  = $this->_TabIndex($intTabIndex);
		$strValue = (($strType == "text") ? $this->_Value($strId, $strValue) : "" );
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);		
		$strClassName = $this->_ClassName($strId);
		$strLocator = $this->_Locator($strId, $strClassName);		
		$strField = "<input id=\"".$strId."\" name=\"".$strId."\" type=\"".$strType."\" value=\"".$strValue."\" class=\"".$strClassName."\"".$strOtherAttributes.$strMaxLength.$strTabIndex.$strLocator." />";
		switch ($position) {
			case 1:{
				return $this->_FormHtmlElement($strLabel, $strField, $strId);
				break;
			}
			case 2:{
				return $this->_FormHtmlElement($strLabel, $strField, $strId,false);
				break;
			}
		}
	} 	
	
	function TextArea($strId, $strLabel, $strValue, $arrOtherAttributes = array(), $intCols = 0, $intRows = 0, $intTabIndex = NULL)
		{
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strValue = $this->_Value($strId, $strValue);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strClassName = $this->_ClassName($strId);
		$strLocator = $this->_Locator($strId, $strClassName);
		$strField  = "<textarea id=\"".$strId."\" name=\"".$strId."\" class=\"".$strClassName."\"".$strOtherAttributes.$strTabIndex.$strLocator.">".$strValue."</textarea>";
		return $this->_FormHtmlElement($strLabel, $strField, $strId);
		}

	function File($strId, $strLabel, $arrOtherAttributes = array(), $intTabIndex = NULL)
		{
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strClassName = $this->_ClassName($strId);
		$strLocator = $this->_Locator($strId, $strClassName);
		$strField  = "<input id=\"".$strId."\" name=\"".$strId."\" type=\"file\" class=\"".$strClassName."\"".$strOtherAttributes.$strTabIndex.$strLocator." />";
		return $this->_FormHtmlElement($strLabel, $strField, $strId);
		}

	function CheckBox($strId, $strLabel, $arrOtherAttributes = array(), $blnChecked = false, $strValue = "1", $intTabIndex = NULL){
		return BM_PHPForm::CheckBox2($strId, $strLabel, $arrOtherAttributes, $blnChecked, $strValue, $intTabIndex,1);	
	}

	function CheckBox2($strId, $strLabel, $arrOtherAttributes = array(), $blnChecked = false, $strValue = "1", $intTabIndex = NULL,$position = 2){
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strClassName = $this->_ClassName($strId);
		if ($this->IsPost())
			$strChecked = ((isset($this->arrPostData[$strId])) ? " checked=\"checked\"" : "" );
		else
			$strChecked = (($blnChecked) ? " checked=\"checked\"" : "" );
		$strField  = "<input id=\"".$strId."\" name=\"".$strId."\" type=\"checkbox\" class=\"".$strClassName."\" value=\"".$strValue."\"".$strChecked.$strOtherAttributes.$strTabIndex." />";
		switch ($position) {
			case 1:{
				return $this->_FormHtmlElement($strLabel, $strField, $strId, true);
				break;
			}
			case 2:{
				return $this->_FormHtmlElement2($strLabel, $strField, $strId, true);
				break;
			}
		}
	}

/*	function CheckBoxs($strId, $strLabel, $arrOptions, $arrOtherAttributes = array(), $blnChecked = false, $intTabIndex = NULL)
		{
		$strOptions = "";
		$strChecked = "";
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strClassName = $this->_ClassName($strId);
		while (list($strKey, $strVal) = each($arrOptions))
			{
			if (isset($this->arrPostData[$strId]))
				{
				$strChecked = ((in_array($this->arrPostData[$strId]) == $strKey) ? " checked=\"checked\"" : "" );
				}
			$strOptions .= $this->strIndent."            <input id=\"".$strId."\" name=\"".$strId."\" type=\"checkbox\" class=\"".$strClassName."\" value=\"".$strKey."\"".$strChecked.$strOtherAttributes.$strTabIndex." >$strVal</input>\r\n";
			}

		$strField  = "\r\n";
		$strField .= $strOptions;
		$strField .= "\r\n"; 			
		return $this->_FormHtmlElement($strLabel, $strField, $strId );
		}	
*/		
	function Select($strId, $strLabel, $arrOptions, $arrOtherAttributes = array(), $strValue = "", $intSize = 0, $blnMultiSelect = false, $intTabIndex = NULL)
		{
		$strOptions  = "";
		$strSelected = "";
		while (list($strKey, $strVal) = each ($arrOptions))
			{
			if (isset($this->arrPostData[$strId]))
				{
				$strSelected = (($this->arrPostData[$strId] == $strKey) ? " selected=\"selected\"" : "" );
				}elseif($strValue!="")
				{
				$strSelected = (($strValue == $strKey) ? " selected=\"selected\"" : "" );
				}
			$strOptions .= $this->strIndent."            <option value=\"".$strKey."\"".$strSelected.">".$strVal."</option>\r\n";
			}
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strSize = (($intSize > 0) ? " size=\"".$intSize."\"" : "" );
		$strMultiSelect = (($blnMultiSelect) ? "multiple=\"multiple\"" : "" );
		$strClassName = $this->_ClassName($strId);
		$strLocator = $this->_Locator($strId, $strClassName);
		$strField  = "\r\n".$this->strIndent."          <select id=\"".$strId."\" name=\"".$strId."\" class=\"".$strClassName."\"".$strTabIndex.$strSize.$strMultiSelect.$strLocator.">\r\n";
		$strField .= $strOptions;
		$strField .= $this->strIndent."          </select>\r\n".$this->strIndent."        ";
		return $this->_FormHtmlElement($strLabel, $strField, $strId);
		}
		
	function Radio($strId, $arrItems, $arrOtherAttributes = array(), $strCheckedItem = "", $intTabIndex = NULL)
		{
		$strFieldCombined = "";
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strClassName = $this->_ClassName($strId);
		while (list($strKey, $strVal) = each($arrItems))
			{
			if ($this->IsPost())
				$strChecked = (($this->arrPostData[$strId] == $strKey) ? " checked=\"checked\"" : "" );
			else
				$strChecked = (($strCheckedItem == $strKey) ? " checked=\"checked\"" : "" );
			$strField  = "<input id=\"".$strId."-".$strKey."\" name=\"".$strId."\" type=\"radio\" class=\"".$strClassName."\" value=\"".$strKey."\"".$strChecked.$strOtherAttributes.$strTabIndex." />";
			$strFieldCombined .= $this->_FormHtmlElement($strVal, $strField, $strId."-".$strKey, true);
			}
		return $strFieldCombined;
		}


	function HiddenField($strId, $strValue)
		{
		$strField = $this->strIndent."      <input id=\"".$strId."\" name=\"".$strId."\" type=\"hidden\" value=\"".$strValue."\" />\r\n";
		return $strField;
		}
	
	function SubmitButton($strId, $strCaption, $arrOtherAttributes = array(), $blnFormat = true, $strClassName = "submit", $intTabIndex = NULL)
		{
		return BM_PHPForm::SubmitButton2($strId, $strCaption, $arrOtherAttributes, $blnFormat, $strClassName, $intTabIndex, 1);
		}
	
	function SubmitButton2($strId, $strCaption, $arrOtherAttributes = array(), $blnFormat = true, $strClassName = "submit", $intTabIndex = NULL, $position = 2){
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strLocator = $this->_Locator($strId, $strClassName);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strField = "<input id=\"".$strId."\" type=\"submit\" value=\"".$strCaption."\" class=\"".$strClassName."\"".$strTabIndex.$strLocator.$strOtherAttributes." />";
		switch ($position) {
			case 1:{
			return (($blnFormat) ? $this->_FormHtmlElement("&nbsp;", $strField, $strId) : $strField );
			break;	
			}
			case 2:{
			return (($blnFormat) ? $this->_FormHtmlElement3("&nbsp;", $strField, $strId) : $strField );
			break;	
			}
		}
	}

	function Button($strId, $strCaption, $arrOtherAttributes = array(), $blnFormat = true, $strClassName = "submit", $intTabIndex = NULL)
		{
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strLocator = $this->_Locator($strId, $strClassName);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strField = "<input id=\"".$strId."\" type=\"button\" value=\"".$strCaption."\" class=\"".$strClassName."\"".$strTabIndex.$strLocator.$strOtherAttributes." />";
		return (($blnFormat) ? $this->_FormHtmlElement("&nbsp;", $strField, $strId) : $strField );
		}

	function Reset($strId, $strCaption, $arrOtherAttributes = array(), $blnFormat = true, $strClassName = "submit", $intTabIndex = NULL)
		{
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strLocator = $this->_Locator($strId, $strClassName);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strField = "<input id=\"".$strId."\" type=\"reset\" value=\"".$strCaption."\" class=\"".$strClassName."\"".$strTabIndex.$strLocator.$strOtherAttributes." />";
		return (($blnFormat) ? $this->_FormHtmlElement("&nbsp;", $strField, $strId) : $strField );
		}

	function Reset2($strId, $strCaption, $arrOtherAttributes = array(), $blnFormat = true, $strClassName = "submit", $intTabIndex = NULL)
		{
		$strTabIndex = $this->_TabIndex($intTabIndex);
		$strLocator = $this->_Locator($strId, $strClassName);
		$strOtherAttributes = $this->_OtherAttributes($arrOtherAttributes);
		$strField = "<input id=\"".$strId."\" type=\"reset\" value=\"".$strCaption."\" class=\"".$strClassName."\"".$strTabIndex.$strLocator.$strOtherAttributes." />";
		return (($blnFormat) ? $this->_FormHtmlElement3("&nbsp;", $strField, $strId) : $strField );
		}

	function StripSlashes($strString)
		{
		if (get_magic_quotes_gpc())
		   return(stripslashes($strString));
		else
		   return($strString);
		}

	function ErrMsgs($strIndent = "")
		{
		if (!$this->IsValid())
			{
			$strErrMsgs = $this->strIndent."<ul id=\"errmsgs\">\r\n";
			foreach ($this->arrErrMsgs as $strMsg)
				$strErrMsgs .= $this->strIndent."  <li>".$strMsg."</li>\r\n";
			$strErrMsgs .= $this->strIndent."</ul>\r\n";
			return $strErrMsgs;
			}
		return false;
		}

	function InfMsgs($strIndent = "")
		{
		if (!$this->IsHavmsg())
			{
			$strInfMsgs = $this->strIndent."<ul id=\"infmsgs\">\r\n";
			foreach ($this->arrInfMsgs as $strMsg)
				$strInfMsgs .= $this->strIndent."  <li>".$strMsg."</li>\r\n";
			$strInfMsgs .= $this->strIndent."</ul>\r\n";
			return $strInfMsgs;
			}
		return false;
		}

	function JsLib()
		{
		$strJsLib  = "<script type=\"text/javascript\">\r\n";
		$strJsLib .= "function ChangeClassName(strMenuId, strClassName)\r\n";
		$strJsLib .= "	{\r\n";
		$strJsLib .= "	var e;\r\n";
		$strJsLib .= "	e = document.getElementById(strMenuId);\r\n";
		$strJsLib .= "	e.className = strClassName;\r\n";
		$strJsLib .= "	}\r\n";
		$strJsLib .= "</script>\r\n";
		return $strJsLib;
		}

	function SetError($strKey, $strValue)
		{
		$this->arrErrMsgs[$strKey] = $strValue;
		return true;
		}

	function SetInfor($strKey, $strValue)
		{
		$this->arrInfMsgs[$strKey] = $strValue;
		return true;
		}

	function SetIndent($strIndent)
		{
		$this->strIndent = $strIndent;
		return true;
		}

	function UseLocator()
		{
		$this->blnLocator = true;
		return true;
		}

	function IsPost()
		{
		if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST")
			return true;
		else
			return false;
		}

	function IsValid()
		{
		if (count($this->arrErrMsgs) == 0)
			return true;
		else
			return false;
		}

	function IsHavmsg()
		{
		if (count($this->arrInfMsgs) == 0)
			return true;
		else
			return false;
		}

	function GetCSS()
		{
		$strCSS = "fieldset
	{
	margin:0;
	padding:0;
	width:500px;
	background:#f9f9f9;
	}

fieldset legend
	{
	font:bold 18px \"Courier New\";
	color:#333333;
	margin:0 0 0 20px;	
	}

#form-items
	{
	padding:10px;
	width:500px;
	font:bold 16px \"Courier New\";
	color:#333333;
	}

#form-items .formfield
	{
	margin:5px 0 5px 0;
	}

#form-items .formfield .label
	{
	text-align:right;
	padding-right:5px;
	width:100px;
	float:left;
	}

#form-items .formfield .field
	{
	width:100px;
	float:left;
	}

#form-items .formfield .field input, #form-items .formfield .field select, #form-items .formfield .field textarea 
	{
	border:1px solid #666666;
	padding:5px;
	font:bold 16px \"Courier New\";
	color:#666666;
	}

#form-items .formfield .field .normal
	{
	background:#fff;
	border-color:#006699;
	}

#form-items .formfield .field .error
	{
	background:#FFF0F0;
	border-color:#cc0000;
	}

#form-items .formfield .field .selected
	{
	background:#E4F5FA;
	border-color:#006699;
	}

#form-items .formfield .field
	{
	background:E4F5FA;
	border-color:#006699;
	width:300px;
	}

#form-items .formfield .field .submit
	{
	background:#fff;
	border-color:#006699;
	}

#form-items .formfield .clear
	{
	clear:both;
	}

#errmsgs
	{
	margin:0;
	font:normal 16px \"Courier New\";
	padding:10px 25px 10px 25px;
	width:470px;
	background:#FFF0F0;
	border:1px solid #cc0000;
	color:#cc0000;
	}
#infmsgs
	{
	margin:0;
	font:normal 16px \"Courier New\";
	padding:10px 25px 10px 25px;
	width:470px;
	background:#F0FFF0;
	border:1px solid #00cc00;
	color:#00cc00;
	}";
		print $strCSS;
		}
	
	function GetClassInfo()
		{
		$arrClassInfo = array();
		$arrClassInfo['strClassName'] = $this->strClassName;
		$arrClassInfo['strVersion'] = $this->strVersion;
		$arrClassInfo['strAuthor'] = $this->strAuthor;
		$arrClassInfo['strEmail'] = $this->strEmail;
		$arrClassInfo['strUrl'] = $this->strUrl;
		$arrClassInfo['strDate'] = $this->strDate;
		return $arrClassInfo;
		}
	// <ValidationMethods>
	function ChEmptiness($strKey, $strMessage)
		{
		if (empty($this->arrPostData[$strKey]))
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}

	function ChEmailAddr($strKey, $strMessage)
		{
		if (preg_match("/^[a-z0-9_\\.\\-]+@+[a-z0-9_\\.\\-]+(\\.[a-z]{2,4})$/", $this->arrPostData[$strKey]) == 0)
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}

	function ChMaxLength($strKey, $strMessage, $intMaxLength)
		{
		if (strlen($this->arrPostData[$strKey]) > $intMaxLength)
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}

	function ChMinLength($strKey, $strMessage, $intMaxLength)
		{
		if (strlen($this->arrPostData[$strKey]) < $intMaxLength)
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}

	function ChValidChrs($strKey, $strMessage, $strChrs)
		{
		if (!$this->_ValidateChars($this->arrPostData[$strKey], $strChrs))
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}

	function ChWithRegex($strKey, $strMessage, $strPattern)
		{
		if (preg_match($strPattern, $this->arrPostData[$strKey]) === 0)
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}	

	function ChCustomVal($strKey, $strMessage, $blnValidation)
		{
		if (!$blnValidation)
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}	

	function ChFileExist($strKey, $strMessage)
		{
		if ($_FILES[$strKey]['name'] == "")
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}

	function ChFileTypes($strKey, $strMessage, $arrFileTypes)
		{
		$blnFlag = false;
		foreach($arrFileTypes as $strFileType)
			{
			if (strtoupper($_FILES[$strKey]['type']) == strtoupper($strFileType))
				$blnFlag = true;
			}
		if (!$blnFlag)
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}

	function ChFileMaxSZ($strKey, $strMessage, $intMaxSize)
		{
		if ($_FILES[$strKey]['size'] > $intMaxSize)
			return $this->_SetError($strKey, $strMessage);
		else
			return true;
		}
	// </Validation Methods>
	
	// <Private Methods>
	function _Locator($strId, $strClassName)
		{
		$strLocator = (($this->blnLocator) ?  " onfocus=\"javascript:ChangeClassName('".$strId."', 'selected');\" onblur=\"javascript:ChangeClassName('".$strId."', '".$strClassName."');\"" : "" );
		return $strLocator;
		}
	
	function _ClassName($strId)
		{
		$strClassName = ((isset($this->arrErrMsgs[$strId])) ? "error" : "normal" );
		return $strClassName;
		}

	function _Value($strId, $strValue)
		{
		$strValue = htmlspecialchars(((isset($this->arrPostData[$strId])) ? $this->StripSlashes($this->arrPostData[$strId]) : $strValue ));
		return $strValue;
		}

	function _TabIndex($intTabIndex)
		{
		$strTabIndex = (($intTabIndex != NULL) ? " tabindex=\"".$intTabIndex."\"" : "" );
		return $strTabIndex;
		}

	function _OtherAttributes($arrOtherAttributes)
		{
		$strOtherAttributes = "";
		while(list($strArrKey, $strArrValue) = each($arrOtherAttributes))
			{
			$strOtherAttributes .= " ".$strArrKey."=\"".$strArrValue."\"";
			}
		return $strOtherAttributes;
		}

	function _FormHtmlElement($strLabel, $strField, $strId, $blnFlip = false){
		$strPlaceHolder  = $this->strIndent."      <div id=\"formfield-".$strId."\" class=\"formfield\">\r\n";
		if ($blnFlip){
			$strPlaceHolder .= $this->strIndent."        <div class=\"label\">&nbsp;</div>\r\n";
			$strPlaceHolder .= $this->strIndent."        <div class=\"field\">".$strField." ".(($strId != NULL) ? "<label for=\"".$strId."\">" : "" ).$strLabel.(($strId != NULL) ? "</label>" : "" )."</div>\r\n";
		}
		else{
			$strPlaceHolder .= $this->strIndent."        <div class=\"label\">".(($strId != NULL) ? "<label for=\"".$strId."\">" : "" ).$strLabel.(($strId != NULL) ? "</label>" : "" )."</div>\r\n";
			$strPlaceHolder .= $this->strIndent."        <div class=\"field\">".$strField."</div>\r\n";
		}
		$strPlaceHolder .= $this->strIndent."        <div class=\"clear\"></div>\r\n";
		$strPlaceHolder .= $this->strIndent."      </div>\r\n";
		return $strPlaceHolder;
	}

	function _FormHtmlElement2($strLabel, $strField, $strId, $blnFlip = false){
		if ($blnFlip){
			$strPlaceHolder .= $this->strIndent."        <div class=\"field\">".$strField." ".(($strId != NULL) ? "<label for=\"".$strId."\">" : "" ).$strLabel.(($strId != NULL) ? "</label>" : "" )."</div>\r\n";
		}
		else{
			$strPlaceHolder .= $this->strIndent."        <div class=\"label\">".(($strId != NULL) ? "<label for=\"".$strId."\">" : "" ).$strLabel.(($strId != NULL) ? "</label>" : "" )."</div>\r\n";
			$strPlaceHolder .= $this->strIndent."        <div class=\"field\">".$strField."</div>\r\n";
		}
		return $strPlaceHolder;
	}

	function _FormHtmlElement3($strLabel, $strField, $strId, $blnFlip = false){
		if ($blnFlip){
			$strPlaceHolder .= $this->strIndent."        ".$strField." ".(($strId != NULL) ? "<label for=\"".$strId."\">" : "" ).$strLabel.(($strId != NULL) ? "</label>" : "" )."\r\n";
		}
		else{
			$strPlaceHolder .= $this->strIndent."        ".$strField."\r\n";
		}
		return $strPlaceHolder;
	}

	function _ValidateChars($strVal, $strAllowdChars)
		{
		for ($i=0; $i<strlen($strVal); $i++)
			{
			if (strpos($strAllowdChars, substr($strVal, $i, 1)) === false)
				return false;
			}
			return true;
		}

	function _SetError($strKey, $strMessage)
		{
		if (!isset($this->arrErrMsgs[$strKey]))
			$this->SetError($strKey, $strMessage);
		return false;
		}
		// </Private Methods>
	}
?>